﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSunny.Admin.Controls
{
    public partial class AddAccountATM : System.Web.UI.UserControl
    {
        public string filePathATM;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAddBank_Click(object sender, EventArgs e)
        {
            if (txtName.Text != "")
            {
                if (txtNumberATM.Text != "")
                {

                    if (fulImageBank.HasFile)
                    {
                        if (LIB.Validate.CheckFileType(fulImageBank.FileName))
                        {
                            string linkimage = fulImageBank.FileName;
                            LIB.Validate saveimage = new LIB.Validate();
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Icons/Icons_Bank/"), linkimage, 100, fulImageBank.PostedFile.InputStream);
                            filePathATM = "/Icons/Icons_Bank/" + fulImageBank.FileName;
                            string values = "'" + filePathATM + "',N'" + txtName.Text + "',N'" + txtNumberATM.Text + "','" + DateTime.Now.ToString() + "'";
                          
                            DAL.DCollector.DBCollector.Instance.StoredInsert("tbl_Bank", values);
                            Response.Redirect("/Admin/Index.aspx?panel=0&sub=4");
                        }
                        else
                        {
                            Response.Write("<script>alert('Chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('Vui lòng upload ảnh ngân hàng...')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Vui lòng nhập số tài khoản...')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('Vui lòng nhập tên tài khoản...')</script>");
            }
        }


    }
}